<?php
/**
 * Created by PhpStorm.
 * User: guobao
 * Date: 2018/6/16
 * Time: 10:33
 */
namespace menghe\core;

class Boot
{
    public static function run(){
        $whoops = new \Whoops\Run;
        $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler);
        $whoops->register();
        //初始化
        self::init();
        //引入助手函数 在conposer.json files 中配置
        //执行应用程序
        self::appRun();


    }
    private static function init(){
        session_id()||session_start();
        date_default_timezone_set('PRC');
    }
    private static function appRun(){
        $module = isset($_GET['m'])?$_GET['m']:'home';
        $controller = isset($_GET['c'])?$_GET['c']:'Entry';
        $action = isset($_GET['a'])?$_GET['a']:'index';
        define('MODULE',$module);
        define('CONTROLLER',$controller);
        define('ACTION',$action);
        $class = '\app\\'.MODULE.'\controller\\'.ucfirst(CONTROLLER);
        $className = new $class;
        echo $className->$action();
    }
}